    var vessul = 0;
	var coffee_fill='';
	function drawCupAnimation()
	{
		
		var tval = coffee_fill.split('-');
		
		var delay=1000;
		setTimeout(function(){						
			var num = parseInt(tval[0]);
			var topcup = 306-num;
			var dropTop = 85 - num;				
			$('.coffee_mug1').css('height',num + 'px');
			$('.coffee_mug').css('height',topcup + 'px');			
			vessul = -num;			
			$('#coffee_drop').css('height', parseInt(347 - num) +'px');
			$('#coffee_click_num').text(tval[1]);		
		},delay);
	
	}
	function initialCup()
	{
		var data = {
				'coffee_init':1				
		};
		$.ajax({
				type:'post',
				url:'ajax.php',
				data:data		
			}).done(function(res_coffee_fill)
			{	
				coffee_fill = res_coffee_fill;
				drawCupAnimation();
			
			});
		
	
	}
	
	var animationTimer = null;
	var currentbgx = 0;
	var animDiv = null;
	
	function startAnimation()
	{
		if(animationTimer == null)
		{
			animationTimer = setInterval(playAnimation, 50);
		}
	}
	
	function stopAnimation()
	{
		clearInterval(animationTimer);
		animationTimer = null;
		drawCupAnimation();
	}
	
	function playAnimation()
	{
		if(animDiv == null)
		{
			animDiv = document.getElementById("coffee_drop");
		}
		
		animDiv.style.backgroundPosition = currentbgx + "px "+vessul + "px";
		currentbgx -= 50;
		if (currentbgx < -1150) {
			currentbgx = 0;
			stopAnimation();
			drawCupAnimation();		
		}
	}	
	$(document).ready(function(){
		$('#fill_click, #m_fill_click').click(function()
		{		
			var data = {
				'coffee_clicks':1				
			};			
			$.ajax({
				type:'post',
				url:'ajax.php',
				data:data		
			}).done(function(res_coffee_fill)
			{			
				coffee_fill = res_coffee_fill
				startAnimation();
			});				
		});	
	});